<!-- pass a variable to included page -->
<%@ page import="SSP.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%  
   String today = null;
   Today t = new Today();
   today = t.getToday();
   request.setAttribute("picture","Service");
   request.setAttribute("title", "Service Order Details");  
   request.setAttribute("header", "Welcome " + 
   		session.getAttribute("firstname") + " " + 
   		session.getAttribute("lastname") + 
   		" : Today is " + today); 
 %>
 <%@ include file="header.jsp"%>
<TD width="850" vAlign="top"> 
<br /><h2>Service Order Details</h2><br />		
<%
int myserviceorderid = Integer.parseInt(request.getParameter("serviceorderid"));
ResultSet rs = null;
String serviceorderid = null;
String serviceorderstatus = null;
String customername = null;
String priority = null;
String servicetype = null;
String opendate = null;
String address1 = null;
String address2 = null;
String CityStateZip = null;
String name = null;
String phone = null;
String email = null;
String equipmentid = null;
String productname = null;
String modality = null;
String problemdescription = null;
String timeestimate = null;

ServiceOrder so = new ServiceOrder();
rs = so.getServiceOrderDetails(myserviceorderid);
while (rs.next()) {
    serviceorderid =  rs.getString("serviceorderid");
    customername = rs.getString("CustomerName");
    serviceorderstatus =  rs.getString("soStatusDescription");
	priority = rs.getString("PriorityDescription");
    servicetype = rs.getString("ServiceTypeDescription");
    opendate = rs.getString("opendate");
    address1 = rs.getString("address1");
    address2 = rs.getString("address2");
    if (address2 == null) {address2 = " ";}
    CityStateZip = rs.getString("CityStateZip");
    name = rs.getString("contactname");
    phone = rs.getString("contactphone");
    email = rs.getString("contactemail");
    equipmentid = rs.getString("equipmentid");
    productname = rs.getString("productname");
    modality = rs.getString("ModalityDescription");
    problemdescription = rs.getString("problemdescription");
    timeestimate = rs.getString("TimeEstimate");
    if (timeestimate == null) {timeestimate = "";}

}
rs.close();
so.closeConnection();
%>

<table width=50% border=0>
<tr><td>Service Order No:</td><td><%=serviceorderid%></td></tr>
<tr><td>Customer:</td><td><%=customername%></td></tr>
<tr><td>Current Status:</td><td><%=serviceorderstatus%></td></tr>
<tr><td>Time Estimate (Hours):</td><td><%=timeestimate%></td></tr>
<tr><td>Priority:</td><td><%=priority%></td></tr>
<tr><td>Service Type:</td><td><%=servicetype%></td></tr>
<tr><td>Date:</td><td><%=opendate%></td></tr>
<tr><td>Contact Name:</td><td><%=name%></td></tr>
<tr><td>Contact Phone:</td><td><%=phone%></td></tr>
<%if (email==null){email="";}%>
<tr><td>Contact Email:</td><td><%=email%></td></tr>
<tr><td>Location:</td><td><%=address1%></td></tr>
<%
if (address2 == " "){ %>
	<tr><td>&nbsp;</td><td><font size=2><%=CityStateZip%></font></td></tr>
<% } 
else {  %>
	<tr><td>&nbsp;</td><td><%=address2%></td></tr>
	<tr><td>&nbsp;</td><td><%=CityStateZip%></td></tr>
<% } %>
</table> 

<hr><br><h3>Equipment Detail</h3>
<table width=100% border=0 cellpadding=3 cellspacing=1>
	<tr>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Equipment Nbr</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Product</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Modality</th>
	</tr>
	<tr>
		<td bgcolor="whitesmoke" style="text-align:center;"><FONT color="#ff0066">&gt;</FONT> <a href=equipmentdetails.jsp?equipmentid=<%=equipmentid%>><%=equipmentid%></a></td>
		<td bgcolor="whitesmoke" style="text-align:center;"><%=productname%></td>
		<td bgcolor="whitesmoke" style="text-align:center;"><%=modality%></td></tr>
</table>
			
<hr /><br /><h4>Problem Description</h4>
<% if(problemdescription==null){problemdescription="";} %>
<p><textarea rows=3 cols=100 readonly><%=problemdescription%></textarea></p>

<hr /><br /><h4>Action Log</h4>
<table width=100% border=0 cellpadding=3 cellspacing=1>
	<tr>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Action Number</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Check-In</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Check-Out</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Technician</th>
		<th bgcolor="#3B73B9" style="text-align:center; color:white;">Notes</th>
	<%
		String rowcolor = "whitesmoke";
 		String textcolor = "black";
 		String myRowColor = rowcolor;
 		String notes = null;
 		String checkout = null;
 		rs = so.getActionDetails(myserviceorderid);
 		int i = 1;
 		while (rs.next()) {
 			 
 			 if (rs.getString("checkout") == null) {checkout = "";}
 			 else {
 			 	checkout = rs.getString("checkout");
 			 }
  %>
			
			
			<tr>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=i%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("checkin")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=checkout%></font></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("name")%></td>
			
			<%
			    notes = rs.getString("actionnotes");
				if (notes == null) {notes = ""; }
			 %>
			
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=notes%></td>
			</tr>
			
			
  <%
       
      if (rowcolor.equals(myRowColor)) {
      		rowcolor = "white";
     		textcolor = "black";
 		 }
  		else   {
      		rowcolor = myRowColor;
      		textcolor = "black";
  		}
  		
  		i++;
    }
 rs.close();  
 so.closeConnection();
 %>
 
 </table>
 		
<br>		 
<form name=form1 method=post action=soaccepted.jsp>
	<input type=hidden name="serviceorderid" value="<%=serviceorderid%>">
	<input type=button value=Back onClick="location.replace('customerhome.jsp')">
</form>	
</td></tr></table></body></html>